<template>
  <div class="header">
    <div class="header-return"
    v-show="showHeader">
      <span class="border-return" @click="toHome"></span>
      <span class="iconfont return" @click="toHome">&#xe624;</span>
    </div>
   
      <div class="header-top" v-show="!showHeader"
      :style="styleOpacity">
          <div class="header-left">
               <span class="iconfont" @click="toHome"> &#xe624; </span>
               <span class="bj">北京国际电影节</span>
               
          </div>
        
      </div>
 
  </div>
</template>

<script>
export default {
  name: "header",
  data(){
      return{
          showHeader:true,
          styleOpacity:{
              opacity:0
          }
      }
  },
  methods:{
      toHome(){
        this.$router.push("/")
      }
  },
  mounted(){
      let that=this;
      window.addEventListener("scroll",function(){
          let top=this.document.documentElement.scrollTop;
          if(top>45){
              let opacity=top/130;
              opacity=opacity>1?1:opacity;
              that.styleOpacity={opacity}
              that.showHeader=false
          }else{
               that.showHeader=true
          }
      })
  }

};
</script>

<style scoped lang="stylus">
@import '../../../assets/css/var.styl';
.header-return {
  position: absolute;
  left: 0.1rem;
  top: 0.1rem;
  width: 0.72rem;
  height: 0.72rem;
}
.border-return {
  display: block;
  background: #000;
  width: 0.72rem;
  height: 0.72rem;
  opacity: 0.5;
  border-radius: 0.36rem;
}
.return {
  position: absolute;
  left: 0.18rem;
  top: 0.18rem;
  color: #fff;
  font-size: 0.32rem;
  font-weight: bold;
}


.header-top {
  position:fixed;
  z-index:999;
  top:0;
  width: 100%;
  line-height: 0.88rem;
  background: $bgColor;
  color: $textColor;
  font-size: 0.36rem;
  display: flex;
}

.header-left {
  padding: 0 0.2rem;
  text-align: center;
  font-weight: bold;
   
}
.header-left .bj{
     margin-left:90px;
}
</style>